//
//  BaiKeMainSectionHeaderView.m
//  BaseProject
//
//  Created by mac on 2020/12/21.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "BaiKeMainSectionHeaderView.h"
#import "BaiKeMainModel.h"
@interface BaiKeMainSectionHeaderView ()
@property(nonatomic,strong)UIImageView *leftIV;
@property(nonatomic,strong)UILabel *titleLab;
@property(nonatomic,strong)BaseAdjustButton *moreButton;
@end

@implementation BaiKeMainSectionHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = WhiteColor;
    }
    return self;
}
- (void)setListModel:(BaiKeSubListDataListModel *)listModel
{
    _listModel = listModel;
    self.titleLab.text = listModel.threeName;
    [self leftIV];
    [self moreButton];
}
#pragma mark - click
- (void)clickMoreButton:sender
{
    if ([self.delegate respondsToSelector:@selector(baiKeMainSectionHeaderViewSection:backType:)]) {
        [self.delegate baiKeMainSectionHeaderViewSection:self.section backType:0];
    }
}
#pragma mark - lazy懒加载
- (UILabel *)titleLab
{
    if (!_titleLab) {
        UILabel *lab = [[UILabel alloc]init];
        [self addSubview:lab];
        lab.font = [UIFont systemFontOfSize:16*ADAPTER_WIDTH weight:UIFontWeightMedium];
        lab.textColor = rgba(51, 51, 51, 1);
        lab.textAlignment = NSTextAlignmentLeft;
        lab.numberOfLines = 1;
        lab.frame = CGRectMake(23*ADAPTER_WIDTH, 15*ADAPTER_WIDTH, WIDTH - 100*ADAPTER_WIDTH, 22*ADAPTER_WIDTH);
        _titleLab = lab;
    }
    return _titleLab;
}
- (UIImageView *)leftIV
{
    if (!_leftIV) {
        UIImageView *iv = [[UIImageView alloc]init];
        [self addSubview:iv];
        iv.image = [UIImage getPNGimageInBundleWithName:@"BaiKe_doline"];
        iv.frame = CGRectMake(14*ADAPTER_WIDTH, 0, 3*ADAPTER_WIDTH, 18*ADAPTER_WIDTH);
        iv.centerY = self.titleLab.centerY;
        _leftIV = iv;
    }
    return _leftIV;
}
- (BaseAdjustButton *)moreButton
{
    if (!_moreButton) {
        BaseAdjustButton *button = [BaseAdjustButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:button];
        button.type = layoutTypeHorizontalLeftTitleRightImage;
        button.title = @"更多";
        button.fontWeight = UIFontWeightRegular;
        button.fontSize = 14*ADAPTER_WIDTH;
        button.imageWidth = 7*ADAPTER_WIDTH;
        button.imageHeight = 13*ADAPTER_WIDTH;
        button.marginLeft = 50*ADAPTER_WIDTH;
        button.marginItemX = 3*ADAPTER_WIDTH;
        button.marginRight = 14*ADAPTER_WIDTH;
        button.marginTop = 10*ADAPTER_WIDTH;
        button.marginBottom = 10*ADAPTER_WIDTH;
        [button begin];
        button.centerY = self.leftIV.centerY;
        button.left = WIDTH - button.width;
        [button setTitleColor:kColor153 forState:UIControlStateNormal];
        [button setImage:[UIImage getPNGimageInBundleWithName:@"BaiKe_right"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(clickMoreButton:) forControlEvents:UIControlEventTouchUpInside];
        _moreButton = button;
    }
    return _moreButton;
}
@end
